﻿using System;
using l1cs.server.model.Instance;
using System.Xml;
using System.Collections;
namespace l1cs.server.model.npc.action
{
    public class L1NpcSetQuestAction : L1NpcXmlAction
    {
        private int _id;
        private int _step;

        public L1NpcSetQuestAction()
        {
        }

        public L1NpcSetQuestAction( XmlReader reader )
            : base( reader )
        {
            Hashtable attribute = L1NpcXmlParser.getAllAttribute( reader );
            _id = L1NpcXmlParser.parseQuestId( (string)attribute["Id"] );
            _step = L1NpcXmlParser.parseQuestStep( (string)attribute["Step"] );

            if ( _id == -1 || _step == -1 )
            {
                throw new Exception();
            }
        }

        //@Override
        override public L1NpcHtml execute( String actionName, L1PcInstance pc, L1Object obj, byte[] args )
        {
            pc.getQuest().set_step( _id, _step );
            return null;
        }
    }
}